﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NGUYENTHUTRANG
{
    public partial class dowhile : Form
    {
        int i = 0;
        public dowhile()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string strout = "";
            if (string.IsNullOrEmpty(txtnhap.Text))
            {
                MessageBox.Show("Bạn chưa nhập dãy");
            }
            else
            {
                if (string.IsNullOrEmpty(cboxCL.Text))
                {
                    MessageBox.Show("Bạn chưa chọn kiểu giá trị");
                }
                else
                {

                    int n = Convert.ToInt32(txtnhap.Text);
                    if (strout == "")
                    {
                        do
                        {
                            if (cboxCL.Text == "Chẵn")
                            {
                                if (i % 2 == 0)
                                {

                                    strout = strout + i.ToString() + "-";
                                    i = i + 1;
                                }
                                lbllan.Text = i.ToString();
                                lblketqua.Text = strout + i.ToString() + "-";
                             // lblketqua.Text = strout.Substring(0, strout.Length - 1);

                            }
                            else
                            {
                                if (i % 2 != 0)
                                {

                                    strout = strout + i.ToString() + "-";
                                    i = i + 1;
                                }
                                lbllan.Text = strout;
                                lblketqua.Text = strout + i.ToString() + "-";
                               // lblketqua.Text = strout.Substring(0, strout.Length - 1);
                            }

                        } while (i <= n);
                    }
                }
            }
        }
    }
}
